package com.lh.controller;

import com.alibaba.fastjson2.JSON;
import com.lh.vo.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: linghao
 * @since: 2023/7/27
 */

@RestController
public class RedisDemo {

    @Autowired
    private RedisTemplate redisTemplate;


    @GetMapping("/redistest")
    public String testC23(){
        redisTemplate.opsForHash().put("test1","test1-1","123");
        redisTemplate.opsForHash().put("test1","test1-1","12345");
        System.out.println(redisTemplate.opsForHash().get("test1","test1-1"));
        Map<String,String> map = new HashMap<>();
        map.put("test2","123");
        map.put("test3","1234");
        map.put("test4","12345");
        redisTemplate.opsForHash().putAll("map1",map);
        System.out.println(redisTemplate.opsForHash().entries("map1"));
        Map<String,String> map2 = new HashMap<>();
        map2.put("test21","123");
        map2.put("test3","12xx34");
        map2.put("test4","123xxx45");
        redisTemplate.opsForHash().putAll("map1",map2);
        System.out.println(redisTemplate.opsForHash().entries("map1"));
        return "ok";
    }

}
